package com.yami.shop.dao;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.yami.shop.bean.dto.BlockchainShopDTO;
import com.yami.shop.bean.model.Blockchain;
import com.yami.shop.bean.model.BlockchainShop;
import com.yami.shop.bean.vo.BlockchainShopVO;
import com.yami.shop.common.util.PageParam;
import org.apache.ibatis.annotations.Param;

import java.util.List;

/**
 * @Author lth
 * @Date 2021/7/21 16:23
 */
public interface BlockchainShopMapper extends BaseMapper<BlockchainShop> {

    /**
     * 批量保存链平台签约信息
     *
     * @param blockchainShopList
     * @param shopId
     * @param status
     */
    void saveBatch(@Param("blockchainShopList") List<BlockchainShop> blockchainShopList, @Param("shopId") Long shopId, @Param("status") Integer status);

    /**
     * 根据店铺id获取签约链平台信息列表
     *
     * @param shopId
     * @return
     */
    List<BlockchainShopVO> listSigningBlockchainByShopId(@Param("shopId") Long shopId);

    /**
     * 获取店铺签约成功的链平台信息列表
     *
     * @param shopId
     * @param status
     * @return
     */
    List<BlockchainShopVO> listSigningBlockchainByShopIdAndStatus(@Param("shopId") Long shopId, @Param("status") int status);


    /**
     * 根据店铺id、链平台id获取折扣率
     *
     * @param shopId       店铺id
     * @param blockchainId 链平台id
     * @return 平台佣金
     */
    List<BlockchainShop> listDiscountByShopIdAndBlockchainId(Long shopId, Long blockchainId);

    /**
     * 根据链平台id列表获取店铺id列表
     *
     * @param blockchainIds
     * @return
     */
    List<Long> listShopIdByBlockchainIds(@Param("blockchainIds") List<Long> blockchainIds);

    /**
     * 根据店铺id与状态更改签约状态
     *
     * @param shopId
     * @param oldStatus
     * @param newStatus
     */
    void changeStatusByShopIdAndStatus(@Param("shopId") Long shopId, @Param("oldStatus") Integer oldStatus, @Param("newStatus") Integer newStatus);

    /**
     * 分页获取链平台签约信息
     *
     * @param page
     * @param BlockchainShop
     * @return
     */
    IPage<BlockchainShopVO> pageSigningInfo(@Param("page") PageParam<BlockchainShopVO> page, @Param("blockchainShop") BlockchainShopDTO BlockchainShop);

    /**
     *  根据店铺id查询未申请铸币权限链
     *
     * @param shopId
     * @param applyId  申请id,不为空时排除该id
     * @return
     */
    List<BlockchainShopVO> listByIsCoin(@Param("shopId") Long shopId, @Param("applyId") Long applyId);
}
